The present invention relates to a variable-length decoding apparatus for decoding encoded data formed from a variable length code used for compression encoding of, e.g., a video signal, and a decoding method.
A variable length code is a code system for generating a code having a short average code length by respectively assigning a code having a short code length to a frequently occurring symbol and a code having a long code length to a rarely occurring symbol on the basis of the frequencies of occurrence of symbols. By using variable length codes, therefore, the amount of data can be greatly compressed as compared with the data before encoding. For this reason, variable length codes are widely used as codes for information compression.
In a video encoding system as well, variable length codes are used for a general standard scheme such as MPEG1, MPEG2, H.261, or H.263.
A general problem associated with variable length codes is that when an error is mixed in encoded data due to a channel error or the like, the encoded data mixed with the error cannot be properly decoded by a decoding apparatus owing to the influences of the error. In order to prevent this problem, when an error can occur in a transmission channel, a method of preventing the propagation of an error by inserting sync codes in data at given intervals is generally used. A bit pattern that does not appear by any combination of variable length codes is assigned to a sync code. According to this method, even if an error occurs in encoded data and the data cannot be decoded, the propagation of the error can be prevented by resuming decoding upon detection of the next sync code, thereby continuing the decoding.
Even with the use of sync codes, however, decoding cannot be performed for encoded data between the position where an error has occurred and decoding cannot be performed and the position where the next sync code is detected.
A variable-length decoding/encoding apparatus which can reduce the portion, which cannot be decoded, by using variable length codes that can be decoded bidirectionally, i.e, forward and backward and performing backward decoding upon detection of a next sync code, has been proposed in the patent application (Japanese Patent Application Nos. 7-260383 and 9-81614) filed by the present applicant.
Even with such a variable-length encoding/decoding apparatus, an error in encoded data can be detected only when, for example, a bit pattern that is not used as a code word of a variable-length code appears.
For this reason, in some case, an error is detected at a succeeding position considerably away from the position where the error is actually mixed in the data. This is because a bit pattern that is not used as a code word of a variable length code does not always appear at the position where the error is actually mixed in the data, and decode processing is continuously performed as long as a corresponding portion is present in the bit patterns used as the code words of the variable length code. As a result, an incorrect word code is erroneously decoded as a correct code word.
Various methods have been examined as countermeasures against channel errors in a video encoding/decoding apparatus. For example, several methods as countermeasures against channel errors are disclosed in a literature (Hideo Kuroda, xe2x80x9cImage Coding Techniquexe2x80x9d, Shokodo, 1996). Of these methods, error concealment is introduced as a technique used on the decoder side. Error concealment is a technique of minimizing the influences of an error on a frame by using motion vectors on the peripheral portion of the frame upon occurrence of a loss of encoded data.
If, however, an incorrect code word is decoded as a correct code word, a technique of minimizing the influences of an error, such as the above error concealment, cannot be used. As a result, the frame is affected by the error.
The influences of an error in the INTRA mode (intraframe encoding mode) are larger than those in the INTER mode (interframe encoding mode), and a block in unnatural color appears on a frame.
As described above, in the conventional variable-length decoding apparatus, when a variable length code is decoded, an incorrect code word may be decoded as a correct word. If, therefore, this apparatus is applied to decoding of a variable length encoded video signal, a frame is affected by an error.
It is an object of the present invention to provide a variable-length decoding apparatus and a decoding method which can decrease the possibility that an incorrect code word is erroneously decoded as a correct word, and can realize sufficient resistance to errors.
According to the present invention, there is provided a variable-length decoding apparatus comprising an input unit for receiving encoded data formed from a variable length code made up of code words that can be decoded in both a forward direction and a backward direction, a forward decoder for decoding the encoded data in the forward direction, a backward decoder for decoding the encoded data in the backward direction, and a decode value determination unit for outputting a final decode result from decode results respectively obtained by the forward decoder and the backward decoder, wherein each of the forward and backward decoders includes a detection unit for detecting an error in the encoded data, and the decode value determination unit determines a decode value by using error detection positions in the encoded data in units of bits and syntax, which are detected by the forward decoder and indicate an error position in the encoded data, and error detection positions in the encoded data in units of bits and syntax, which are detected by the backward decoder and indicate an error position in the encoded data.
In this variable-length decoding apparatus, when errors are detected by the forward and backward decoders, the decode value determination unit is notified of the error detection positions as two types of position information, i.e., positions in units of bits and positions in units of syntax. The true error position can therefore be checked doubly on the basis of the error detection positions in units of bits and the error detection positions in units of syntax. This allows the use of only decode results corresponding to correct code words with a considerably high probability, and hence can decreases the possibility of erroneously decoding an incorrect code word as a correct code word.
In addition, the decode value determination unit preferably uses a decode value determination method of,
(a) using a forward decode result as a decode value for code words up to a position a predetermined amount before the error detection position in units of bit or syntax, which is obtained by the forward decoder, and a backward decode result as a decode value for code words from a position a predetermined amount after the error detection position in units of bits or syntax, which is obtained by the backward decoder, and discarding the remaining encoded data, when the error detection positions obtained by the forward and backward decoders do not cross each other in units of both bits and syntax,
(b) using a forward decode result as a decode value for code words up to a position immediately before the error detection position in units of syntax, which is obtained by the backward decoder, and a backward decode result as a decode value for code words from a position immediately after the error detection position in units of syntax, which is obtained by the forward decoder, and discarding encoded data of a portion on which the error detection positions in units of syntax cross each other, when the error detection positions obtained by the forward and backward decoders do not cross each other in units of bits but cross each other in units of syntax,
(c) using a forward decode result as a decode value for code words up to a position immediately before the error detection position in units of bits, which is obtained by the backward decoder, and a backward decode result as a decode value for code words from a position immediately after the error detection position in units of bits, which is obtained by the forward decoder, and discarding encoded data of a portion on which the error detection positions in units of bits cross each other, when the error detection positions obtained by the forward and backward decoders cross each other in units of bits but do not cross each other in units of syntax, and
(d) selecting a position where a crossing portion becomes largest as an error detection position,
using a forward decode result as a decode value for code words up to a position immediately before the error detection position obtained by the backward decoder and a backward decode result as a decode value for code words from a position immediately after the error detection position obtained by the forward decoder, and discarding encoded data of a portion on which the error detection positions cross each other, when the error detection positions obtained by the forward and backward decoders cross each other in units of both bits and syntax.
Considering that an error detection position in a variable length code succeeds considerably away from the actual error position, in the case (a) in which the error detection positions do not cross each other in both the forward and backward directions, code words up to a position set by retracting the encoded data by a predetermined amount from each error detection position are used. In the cases (b) to (d) in which the error detection positions in the forward or backward direction cross each other somehow, a portion having a large crossing range is discarded to effectively prevent an incorrect portion from being erroneously determined as a correct portion.
Furthermore, according to the present invention, there is provided a video decoding apparatus comprising an input unit for receiving encoded data of a video signal containing a variable length code generated by encoding transform coefficients obtained by orthogonal transformation of the video signal by using code words that can be decoded in both a forward direction and a backward direction, a sync section detection unit for detecting a sync section of the encoded data, a forward decoder for decoding encoded data in the forward direction in a predetermined sync section detected by the sync section detection unit, a backward decoder for decoding encoded data in the backward direction in a predetermined sync section detected by the sync section detection unit, and a decode value determination unit for outputting a final decode result from decode results obtained by the forward and backward decoders, wherein each of the forward and backward decoders includes an error detection unit for detecting an error in the encoded data, and the decode value determination unit determines a decode value by using error detection positions in the decoded data in units of bits and syntax which indicate an error position in the encoded data which is detected by the forward decoder, and error detection positions in the decoded data in units of bits and syntax which indicate an error position in the encoded data which is detected by the backward decoder.
In general, owing to the characteristics of a video encoding scheme, to determine an incorrect portion as a correct portion influences the display frame more than to discard a correct portion. Therefore, by performing a double check based on error detection positions in units of bits and syntax, the influences exerted in the display frame when an incorrect portion is determined as a correction can be greatly reduced.
The decode value determination unit in this video decoding apparatus preferably uses a decode value determination method of, (a) using a forward decode result as a decode value for macroblocks up to a position a predetermined amount before the error detection position in units of bit or syntax, which is obtained by the forward decoder, and a backward decode result as a decode value for macroblocks from a position a predetermined amount after the error detection position in units of bits or syntax, which is obtained by the backward decoder, and discarding encoded data composed of transform coefficients of the remaining macroblocks, when the error detection positions obtained by the forward and backward decoders do not cross each other as both positions in units of bits and syntax,
(b) using a forward decode result as a decode value for macroblocks up to a position immediately before the error detection position in units of syntax, which is obtained by the backward decoder, and a backward decode result as a decode value for macroblocks from a position immediately after the error detection position in units of syntax, which is obtained by the forward decoder, and discarding encoded data composed of transform coefficients of a macroblock on which the error detection positions in units of syntax cross each other, when the error detection positions obtained by the forward and backward decoders do not cross each other as positions in units of bits but cross each other as positions in units of syntax,
(c) using a forward decode result as a decode value for macroblocks up to a position immediately before the error detection position in units of bits, which is obtained by the backward decoder, and a backward decode result as a decode value for macroblocks from a position immediately after the error detection position in units of bits, which is obtained by the forward decoder, and discarding encoded data composed of transform coefficients of a macroblock on which the error detection positions in units of bits cross each other, when the error detection positions obtained by the forward and backward decoders cross each other as positions in units of bits but do not cross each other as positions in units of syntax, and
(d) selecting a position where a crossing portion becomes largest as an error detection position,
using a forward decode result as a decode value for macroblocks up to a position immediately before the error detection position obtained by the backward decoder and a backward decode result as a decode value for macroblocks from a position immediately after the error detection position obtained by the forward decoder, and discarding encoded data composed of transform coefficients of a macroblock on which the error detection positions cross each other, when the error detection positions obtained by the forward and backward decoders cross each other as both positions in units of bits and syntax.
Considering that an error detection position in a variable length code succeeds considerably away from the actual error position, in the case (a) in which the error detection positions do not cross each other in both the forward and backward directions, macroblocks up to a position set by retracting the encoded data by a predetermined amount from each error detection position are used. In the cases (b) to (d) in which the error detection positions in the forward or backward direction cross each other somehow, a portion having a large crossing range is discarded to prevent the influences of determination of an incorrect portion as a correct portion in the display frame.
When an error is detected in the encoded data in the sync section, the decode value determination unit discards part or all of encoded data composed of macroblock transform coefficients having undergone intraframe encoding within a macroblock in which no error has been detected.
In the intraframe encoding mode, the occurrence of an error greatly influences a frame. More specifically, display of wrong coefficients causes a phenomenon in which a block in unnatural color appears in a frame. If, therefore, at least the occurrence of an error in a sync section is known, the influences of the error on the frame can be reduced by discarding macroblocks in the intraframe encoding mode.
In addition, the decode value determination unit displays a previous frame for a macroblock from which encoded data is discarded or processes the macroblock in a mode without encoding when an intraframe encoding mode is set, and performs motion compensation when an interframe prediction encoding mode is set.
In the intraframe encoding mode, when a DCT coefficient is discarded, since no motion vector is present, a previous frame is displayed, or data is processed in a mode without encoding. In the interframe encoding mode, since a motion vector on the upper layer is present, a considerably natural image can be generated by performing motion compensation using this vector without any DCT coefficient. That is, a DCT coefficient belongs to the lower layer, and a motion vector belongs to the upper layer. If, therefore, an upper motion vector is available, an image can be generated without using any lower DCT coefficient.
Furthermore, according to the present invention, there is provided a variable-length decoding apparatus comprising an input unit for receiving encoded data formed from a variable length code made up of code words including code words that can be decoded in both a forward direction and a backward direction, a forward decoder for decoding the encoded data in the forward direction, a backward decoder for decoding the encoded data in the backward direction, and a decode value determination unit for outputting a final decode result from decode results respectively obtained by the forward decoder and the backward decoder, wherein each of the forward and backward decoders includes a detection unit for detecting an error in the encoded data, and the decode value determination unit estimates a range in which an error is present on the basis of error detection positions detected in the encoded data by the forward and backward decoders, an error rate in a transmission system or storage system, an occurrence probability of each code word, and a bit pattern of each code word in a code word table, thereby determining a final decode value.
In this variable-length decoding apparatus, the probability that an incorrect code word is erroneously decoded as a correct code word can be decreased to a predetermined probability or less by estimating the actual positions of errors from error detection positions in terms of probability in accordance with the error rate in the transmission system or storage system and the performance of code words.